package com.gan.springbootdemo.util;

import lombok.extern.slf4j.Slf4j;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

@Slf4j
public class CalcTimeStamp {

    public static void main(String[] args) {
        String time1 = "2018-07-24 09:40:00";
        String time2 = "2018-07-24 09:41:00";
        String time3 = "2018-07-24 09:40:30";
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date date1;
        Date date2;
        Date date3;
        try {
            date1 = sdf.parse(time1);
            log.info("date1 = {}", date1);
            log.info("date1.getTime = {}", date1.getTime());

            date2 = sdf.parse(time2);
            log.info("date2 = {}", date2);
            log.info("date2.getTime = {}", date2.getTime());

            date3 = sdf.parse(time3);
            log.info("date3 = {}", date3);
            log.info("date3.getTime = {}", date3.getTime());
        } catch (ParseException e) {
            log.error("exception", e);
        }
    }
}
